package 剑指offer;

/**
 * @author zhangjunfei
 * @date 2023/7/19 11:26
 */
public class O_63 {

    public int maxProfit(int[] prices) {
        int cost = Integer.MAX_VALUE, proft = 0;
        for (int price : prices) {
            cost = Math.min(cost, price);
            proft = Math.max(proft, price - cost);
        }
        return proft;
    }
}
